<?php 
//Project Controller
include_once("../service/ServiceProject.php");
include_once("Controller.php");
class ControllerProject extends Controller implements IController 
{
  public function __construct()
  {    
    $this->service = new ServiceProject();
  }
  public function addRec()
  {
    $strduty = !isset($_POST['strduty'])?"":$_POST['strduty'];
    $strname = !isset($_POST['strname'])?"":$_POST['strname'];
    $dtexpect = !isset($_POST['dtexpect'])?"":$_POST['dtexpect'];
    $strdemo = !isset($_POST['strdemo'])?"":$_POST['strdemo'];
    //send the result
    echo (new ServiceProject())->create(array($strname,$strdemo,$strduty,$dtexpect));
    //echo json_encode(array($strname,$strdemo,$strduty,$dtexpect));
    
  }
  public function delRec()
  {
    
  }
  public function updateRec()
  {
    
  }
  public function query()
  {
    
  }
  /**
   *get the detail infomation
   */
  public function detail()
  {
    $strproid = !isset($_GET['strproid'])?"-1":$_GET['strproid'];
    echo $this->service->getDetail($strproid);    
  }
  /**
   *get summary
   */
  public function sum()
  {
    echo (new ServiceProject())->getSum();
  }
  /**
   *get the top 10 record
   */
  public function recent()
  {
    echo $this->service->queryMenu();
  }
}
 ?>